﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace theguineasyndrome
{
    public class Carot : LevelElement
    {
        private const int MOVEMENT_AMPLITUDE = 5;

        private CharacterModel characterModel;

        private Vector2 initialPosition;

        public Carot(Level level, Texture2D texture, CharacterModel characterModel, Vector2 initialPosition)
            : base(level, texture, initialPosition)
        {
            this.level = level;
            this.characterModel = characterModel;
            this.initialPosition = initialPosition - new Vector2(texture.Width, texture.Height) / 2;
        }

        public override void Update(GameTime gameTime)
        {
            Position = initialPosition + new Vector2(0, (float)(Math.Cos(gameTime.TotalGameTime.TotalMilliseconds / 150) * MOVEMENT_AMPLITUDE));
        }

        public override bool isDynamic()
        {
            return true;
        }

        public override void queueDrawing(Camera camera)
        {
            if (camera.isVisible(rectangle))
                level.queueObjectDrawing(this);
        }

        public CharacterModel CharacterModel
        {
            get { return characterModel; }
        }
    }
}
